<!doctype html>
<%@ page import="com.zx.mobile.domain.MobileUserDomain"%>
<%@ page import="com.zx.mobile.SessionHelper"%>
<%@ page contentType="text/html;charset=utf-8" pageEncoding="utf-8"
	language="java"%>
<%@ include file="/jsp/mobile/include/include.jsp"%>
<%
    response.setHeader("Cache-Control", "no-store");
    response.setHeader("Pragrma", "no-cache");
    response.setDateHeader("Expires", 0);
%>
<html lang="cn">
<head>
<%@ include file="/jsp/mobile/include/header.jsp"%>
<title>余额取现</title>
</head>
<body>
<input type="hidden" id="returnUrl" name="returnUrl"  value="javascript:window.jsInjectedObj.goBackMain();"/>
	<%
		MobileUserDomain user = (MobileUserDomain) request.getSession()
				.getAttribute(SessionHelper.MOBILEUSER);
		String bankAccount = user.getMerchantInfoDetailModel()
				.getSettleCardInfoModel().getBankAccount();

		request.setAttribute("lastAccount",
				bankAccount.substring(bankAccount.length() - 4));
	%>
	<div class="main">
		<div class="bkms">
			<dl class="clearfix">
				<dt>
					<img
						src="<%=request.getContextPath()%>/images/mobile/${_MOBILEUSER_.merchantInfoDetailModel.settleCardInfoModel.depositBank}.png">
				</dt>
				<dd>
					<div class="bankNm">
						<p class="tit">
							<common:getDicByCode key="2100"
								value="${_MOBILEUSER_.merchantInfoDetailModel.settleCardInfoModel.depositBank}" />
						</p>

						<p class="con">
							<span>尾号<c:out value="${lastAccount}" /> </span> <span>储蓄卡</span>
						</p>
					</div>
				</dd>
			</dl>
		</div>
		<form id="enchashForm"
			action="<%=request.getContextPath()%>/mobile/index/enchashresult">
			<token:tokenTag></token:tokenTag>
			<div class="ciTab mt15">
				<ul>
					<li><span class="tit">取现类型</span> <span id="tchash"><i
							class="ico ico23"></i>实时到账</span> <span class="m10" id="nchash"><i
							class="ico ico22"></i>次日到账</span>
					</li>
					<li><span class="tit">账户余额</span> <span class="f14 red">￥<fmt:formatNumber
								pattern="#,##0.00"
								value="${null == model.avlBal?0.00:model.avlBal}" /> </span> <input
						type="hidden" name="avlBal" id="avlBal"
						value="<c:out value='${null == model.avlBal?0.00:model.avlBal}' />">
					</li>
				</ul>
			</div>
			<div class="ciTab mt15">
				<ul>
					<li><span class="tit">取现金额</span> <input type="number"
						onfocus="" name="encashAmt" id="encashAmt" class="text"
						placeholder="输入取现金额" autocomplete="off">
					</li>
					<li><span class="tit">支付密码</span> <input name="tradePwd"
						id="tradePwd" type="password" class="text" placeholder="输入支付密码"
						autocomplete="off" maxlength="6">
					</li>
				</ul>
			</div>

			<div class="ctix">
				<p class="f14">温馨提示：</p>

				<p class="gray9 mt5">1.到账时间:实时到账为秒到,次日到账为次日12点和3点两个批次；</p>

				<p class="gray9 mt5">2.取现手续费: 2元/笔;实时到账需额外承担0.1%垫资手续费。</p>
			</div>
			<div class="payOk mb20">
				<div class="nbtn mt20">
					<a class="butn butn-gray" id="confirmAmt"
						href="javascript:enchash();">确认</a>
				</div>

			</div>
			<input type="hidden" name="encashType" id="encashType" value="0">
			<input type="hidden" name="t0RunStatus" id="t0RunStatus"
				value="${t0RunStatus}">
		</form>
	</div>
	<script type="text/javascript">
		$(document).ready(function() {
			changeStyleByValue();
		});
		function enchash() {
			var _encashAmt = $("#encashAmt").val();
			var _encashType = $("#encashType").val();
			var _tradePwd = $("#tradePwd").val();
			var _avlBal = $("#avlBal").val();
			var _msg = "";
			if (parseFloat(_encashAmt) < 10) {
			          _msg += "取现金额需大于或等于10元";
			      }
			/*   if (_encashType == '1') {
			      if (parseFloat(_encashAmt) <= 10) {
			          _msg += "T+1取现金额需大于10元";
			      }
			  }
			  if (_encashType == '0') {
			      if (parseFloat(_encashAmt) <= 2000) {
			          _msg += "即时取现金额需大于2000元";
			      }
			  } */

			if (parseFloat(_encashAmt) > parseFloat(_avlBal)) {
				_msg += "取现金额超出可用余额";
			}

			if (_tradePwd == "") {
				_msg += "请输入支付密码";
			}
			var _t0RunStatus = $("#t0RunStatus").val();
			if (_t0RunStatus == "0" && _encashType == "0") {
				_msg += "即时取现暂不受理";
			}
			if (_msg == "") {
				$("#confirmAmt").removeAttr("href");
				$("#enchashForm").submit();
			} else {
				window.openMsg(_msg, 3);
			}
		}

		$("#nchash").bind("click", function() {
			$("#nchash i").removeClass("ico22").addClass("ico23");
			$("#tchash i").removeClass("ico23").addClass("ico22");
			$("#encashType").val("1");
		});

		$("#tchash").bind("click", function() {
			var _t0RunStatus = $("#t0RunStatus").val();
			if (_t0RunStatus == '1') {//只有TO正常时候 才可取现
				$("#tchash i").removeClass("ico22").addClass("ico23");
				$("#nchash i").removeClass("ico23").addClass("ico22");
				$("#encashType").val("0");
			} else {
				window.openMsg("即时取现暂不受理", 3);
			}
		});

		$("#encashAmt").bind("focus", function() {
			$(this).removeAttr("placeholder");
		});

		$("#encashAmt").bind("blur", function() {
			if ($(this).val() == '') {
				$(this).attr("placeholder", "输入取现金额");
			}
		});

		$("#tradePwd").bind("focus", function() {
			$(this).removeAttr("placeholder");
		});

		$("#tradePwd").bind("blur", function() {
			if ($(this).val() == '') {
				$(this).attr("placeholder", "输入支付密码");
			}
		});

		$("#encashAmt").bind("input propertychange", function() {
			//这里写当input的文字(text)发生改变时所执行的代码！
			changeStyleByValue();
		});

		function changeStyleByValue() {
			var _amt = $("#encashAmt").val();
			if (checkPrice(_amt) && parseFloat(_amt) > 0) {
				$("#confirmAmt").removeClass("butn-gray").attr("href",
						"javascript:enchash();");
			} else {
				$("#confirmAmt").addClass("butn-gray").removeAttr("href");
			}
		}
	</script>
</body>
</html>